<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <script type="text/javascript" src="js/jsAddress.js"></script>
  <title>e网批发管理后台</title>
  <script type="text/javascript" src="js/jquery.min.js"></script>
  <script src="time/js/jquery-ui-1.10.4.custom.min.js"></script>
  <script src="time/js/jquery.ui.datepicker-zh-CN.js"></script>
  <script src="time/js/jquery-ui-timepicker-addon.js"></script>
  <script src="time/js/jquery-ui-timepicker-zh-CN.js"></script>
  <script language="javascript" type="text/javascript" src="datepicker/WdatePicker.js"></script>
  <link href="css/styles.css" rel="stylesheet" type="text/css" />
  <link href="css/style2.css" rel="stylesheet" type="text/css" />
<?php 
include("common/conn.php");  
include("tool/UpFileTool.class.php");
/*if($_GET['action']=="ok"){ 
  if ($_FILES[images][name]!='') {
    $UpFileTool=new UpFileTool('images');
    $images=$UpFileTool->upFile();

  if (empty($_POST[cateids])) {
    $cateids = '';
  }else{
    $cateids = implode(',', $_POST[cateids]);
  }
  $query = mysql_query("INSERT INTO home_activity (name,cateids,images,type) VALUES ('".$_POST[name]."','".$cateids."','".$images."',0)");

    echo "<script>alert('添加成功!');window.location.href='saohuo.php'</script>";
  }else{
    echo "<script>alert('未上传图片!');window.location.href='saohuo.php'</script>";
  }
  
}*/

if($_GET[type]!=''){
  $query = mysql_query("select *  from home_activity where type=".$_GET[type]);
  $activity = mysql_fetch_assoc($query);
}

if($_GET['ch']=="ok"){
  if ($_FILES[images][name]!='') {
    $UpFileTool=new UpFileTool('images');
    $images=$UpFileTool->upFile();
    $query = mysql_query("UPDATE home_activity set shop_down_image='".$images."' where type=".$_POST[type]);
  }

  $query = mysql_query("UPDATE home_activity set shop_down='".$_POST[down]."' where type=".$_POST[type]);
  echo "<script>alert('更新成功!');window.location.href='shopzhekou.php?type=".$_POST[type]."'</script>";
}
?>
</head>

<body>

  <!--header-->
  <?php include("common/header.php");?>
  <!--header end-->
  <div id="sub_nav">

    <div id="subnav_wrap" class="container_12">

      <!-- start sub nav list -->
      <div id="subnav" class=" grid_12">
        <ul>
          <li><a href="xianshizhekou.php?type=2">属性设置</a></li>
          <li><a href="xianshizhekou_img.php?type=2">分类活动图片</a></li>
          <li><a href="xianshizhekou_goods.php?type=2">商品管理</a></li>
          <li><a href="shopzhekou.php?type=2" class="sub_nav_active">商家限时折扣</a></li>
        </ul>
      </div>

    </div>


  </div>

  <div class="container_12">
    <form action="?<?php if($_GET['type']!=""){echo "ch=ok";}else{echo "action=ok";} ?>" method="post" enctype="multipart/form-data"> 
      <table width="100%" border="0" cellpadding="0" cellspacing="0">

        <tr>
          <td width="30%" scope="col"><label>商家限时折扣倒计时</label></td>
          <td width="50%" scope="col">
            <input name="down" type="text" value="<?php echo $activity[shop_down]; ?>" style="cursor:pointer;" onClick="WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss'})"/>
          </td>
        </tr>
         <tr>
          <td width="30%" scope="col"><label>商家限时折扣背景图</label></td>
          <td width="50%" scope="col">
            <input name="images" type="file" class="text"/>
          </td>
        </tr>
        <?php if ($activity[shop_down_image]!='') { ?>
        <tr>
          <td width="30%" scope="col"></td>
          <td width="50%" scope="col">
            <img src="<?php echo $activity[shop_down_image]; ?>" style="height:auto;width:250px;">
          </td>
        </tr>
        <?php } ?>
        <tr>
          <td width="40%" scope="col"></td>
          <td width="50%" scope="col"><input name="type" type="hidden" value="<?php echo $_GET[type];?>" />
            <input name="" type="submit" value="提交" class="submit" />
          </td>
        </tr>
        </table>

      </form>
    </div>

  </form>
  <script type="text/javascript">
    $('#datetimepicker').datetimepicker({
      value:'',
      lang:'ch',
      format:'Y年m月d日',
      step:60,
      timepicker:false,
      datepicker:true
    });
  </script>

</body>
</html>
